﻿var app = app || {};
(function () {
  app.htmlUtils = {
    htmlEncodeText: function (value) {
      return $("<div/>").text(value).html();
    },

    htmlDecodeText: function (value) {
      return $("<div/>").html(value).text();
    },

    htmlEncodeJson: function (jsonObject) {
      return JSON.parse(
        app.htmlUtils.htmlEncodeText(JSON.stringify(jsonObject)),
      );
    },

    htmlDecodeJson: function (jsonObject) {
      return JSON.parse(
        app.htmlUtils.htmlDecodeText(JSON.stringify(jsonObject)),
      );
    },
  };
})();
